/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 18.05.13
 * Time: 4:51
 * To change this template use File | Settings | File Templates.
 */
package {
import flash.geom.Point;

import mx.controls.Label;

public class Weight extends PhysicsObject {
    private var _traction:Number = 0;
    private var _resistance:Number = 0;
    private var tractionLabel:Label;
    private var resistanceLabel:Label;

    public function Weight() {
        draw();

        tractionLabel = new Label();
        tractionLabel.x = 6;
        tractionLabel.y = -15;
        tractionLabel.width = 30;
        tractionLabel.height = 23;
        tractionLabel.text = traction.toString();
        addChild(tractionLabel);

        resistanceLabel = new Label();
        resistanceLabel.x = -20;
        resistanceLabel.y = -2;
        resistanceLabel.width = 30;
        resistanceLabel.height = 23;
        resistanceLabel.text = resistance.toString();
        addChild(resistanceLabel);
    }

    override public function draw():void {
        graphics.clear();
        graphics.beginFill(0xff0000);
        graphics.drawRoundRect(-25, -15, 50, 30, 10, 10);
        graphics.endFill();
    }

    public function get position():Point {
        return new Point(x, -1 * y);
    }

    public function set position(value:Point):void {
        x = value.x;
        y = (-1) * value.y;
    }

    public function get traction():Number {
        return _traction;
    }

    public function set traction(value:Number):void {
        _traction = value;
        tractionLabel.text = traction.toString();
    }

    public function get resistance():Number {
        return _resistance;
    }

    public function set resistance(value:Number):void {
        _resistance = value;
        resistanceLabel.text = resistance.toString();
    }

    public function get movement():Number {
        return _resistance - _traction;
    }
}
}
